package it.rossignoli.enrico.app.Tesi;

import android.app.Activity;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

public class MyArrayAdapter extends ArrayAdapter<String>
{
	private final Activity context;
	private final String[] values;
	private List<String> trained;
	
	public MyArrayAdapter(Activity context,  String[] values2, List<String> trained) 
	{
			super(context, R.layout.rowlayout, values2);
			this.context = context;
			this.values = values2;
			this.trained = trained;
	}
	
	@Override
	public View getView(int position, View convertView, ViewGroup parent) 
	{
		LayoutInflater inflater= context.getLayoutInflater();
		
		View rowView = inflater.inflate(R.layout.rowlayout, null, true);
		TextView testo = (TextView) rowView.findViewById(R.id.label);
		ImageView Icona = (ImageView) rowView.findViewById(R.id.icon);
		ImageView Check = (ImageView) rowView.findViewById(R.id.icon1);
		
		Check.setImageResource(R.drawable.tick_icon);
		
		String s = values[position];
		testo.setText(s);
		
		if(trained.contains(s))
		{
			Icona.setImageResource(R.drawable.tick_icon);
		}
		else
		{
			Icona.setImageResource(R.drawable.x_rossa);
		}
		return rowView;
	}

	
	
	
}
